﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using MSIACCSL2.ViewModels;

namespace MSIACCSL2.Views.Inventory
{
    public partial class Search : ChildWindow
    {
        public InventoryViewModel VM
        {
            get
            {
                return this.DataContext as InventoryViewModel;
            }
        }


        public Search()
        {
            InitializeComponent();
        }

       
    

        private void CancelButton_Click_1(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void txtItem_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                VM.GetItemList(txtItem.Text);
                VM.GridItemVisibility = Visibility.Visible;
            }
        }
      

        private void gridItem_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (gridItem.SelectedIndex != 0 && gridItem.SelectedIndex != VM.Items.Count - 1)
                    gridItem.SelectedIndex -= 1;
                VM.GridItemVisibility = Visibility.Collapsed;
            }
        }
    }
}



